/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.admin.service;

import org.springblade.core.tool.api.R;
import org.springblade.modules.admin.dto.plan.BatchModifyPlanUserDTO;
import org.springblade.modules.admin.entity.MaintainPlanConfig;
import org.springblade.modules.admin.vo.*;
import org.springblade.core.mp.base.BaseService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.modules.admin.vo.defert.PlanConfigVo;
import org.springblade.modules.admin.vo.feishu.LarkMaintainPlanConfigVO;
import org.springblade.modules.admin.vo.openapi.SidaElevatorSchedulesVO;
import org.springblade.modules.admin.vo.task.PlanCheckParam;
import org.springblade.modules.admin.vo.task.PlanTipVO;
import org.springblade.modules.admin.vo.task.SpeedPlanParam;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 保养计划配置 服务类
 *
 * @author ysq
 * @since 2022-03-09
 */
public interface IMaintainPlanConfigService extends BaseService<MaintainPlanConfig> {

	/**
	 * 自定义分页
	 *
	 * @param page
	 * @param maintainPlanConfig
	 * @return
	 */
	IPage<MaintainPlanConfigVO> selectMaintainPlanConfigPage(IPage<MaintainPlanConfigVO> page, MaintainPlanConfigVO maintainPlanConfig);

	/**
	 * 获取该租户保养计划配置下的所有项目集合
	 * @param search
	 * @return
	 */
	List<Map<Long, String>> getBuilidingList(PlanConfigSearchVO search);

	/**
	 * 获取该租户保养计划配置下的所有梯号集合
	 * @param search
	 * @return
	 */
	List<Map<Long, String>> getElevatorList(PlanConfigSearchVO search);

	/**
	 * 获取该租户保养计划配置下的所有梯型式集合
	 * @param search
	 * @return
	 */
	List<Map<Long, String>> getModeTypeList(PlanConfigSearchVO search);

	/**
	 * 获取保养计划集合
	 * @return
	 */
	List<TaskPlanListVO> getTaskPlanList(String keyword);

	/**
	 * 一键排期
	 * @return
	 */
	boolean speedCreatePlan(SpeedPlanParam speedPlanParam);

	/**
	 * 根据电梯id获取保养模板
	 * @param elevatorId
	 * @return
	 */
	List<Map<Long,String>> getTemplateByElevatorId(Long elevatorId);

	/**
	 * 保养排期统计
	 * @param intervalMonth 间隔月数
	 * @return
	 */
	PlanConfigStatisticsVO planConfigStatistics(int intervalMonth);

	/**
	 * 保养排期统计
	 * @param maintainStatus 0-在保，1-脱保
	 * @return
	 */
	PlanCreateStatisticsVO planConfigStatisticsPlus(int maintainStatus);

	/**
	 * 编辑保养配置
	 * @param speedPlanParam
	 * @return
	 */
	boolean editPlanConfig(SpeedPlanParam speedPlanParam);

	/**
	 * 一件排期提示判断
	 * @param planCheckParam
	 * @return
	 */
	List<PlanTipVO> planCheck(PlanCheckParam planCheckParam);


	/**
	 * 根据电梯id获取是否是年审梯
	 * @param elevatorIds 电梯id
	 * @return 数据集
	 */
	List<PlanConfigVo> getPlanConfigVo(List<Long> elevatorIds);

	/**
	 * 列表导出
	 * @param response
	 * @param maintainPlanConfig
	 */
    void down(HttpServletResponse response, MaintainPlanConfigVO maintainPlanConfig) throws IOException;

    List<MaintainPlanConfig> listAll();

	/**
	 * 获取飞书电梯排期合规数据表
	 * @return 飞书电梯排期合规数据表
	 */
    List<LarkMaintainPlanConfigVO> getLarkMaintainPlanConfigVOList();

	List<Map<String,Object>> getBuildingAllList(PlanConfigSearchVO search);

    List<SidaElevatorSchedulesVO> getElevatorSchedulesListByTenantIdAndTime(String tenantId,
																			Date lastMaintainStartTime, Date lastMaintainEndTime,
																			Date previousPlanDateStartTime, Date previousPlanDateEndTime,
																			Date nextPlanDateStartTime, Date nextPlanDateEndTime,
																			Date overdueDateStartTime, Date overdueDateEndTime);

    Map<String, List<VerifyModifyPlanUserResultVO>> verifyModifyPlanUser(BatchModifyPlanUserDTO userDTO);

    Boolean modifyPlanUser(List<VerifyModifyPlanUserResultVO> list);

    List<MaintainPlanConfigVO> selectElevatorByPlanSchComRisks(String tenantId);

    void updateElevatorScheduleLabel(String tenantId);

}
